package org.raymond.iworks.study.example;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.symmetric.AES;

import java.nio.charset.StandardCharsets;


/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class EncryptTest {
    static String key = "0987654321012345";
    static String iv = "abcdefghijklmnop";
    public static void main(String[] args) {
        AES aes = new AES("CBC", "PKCS7Padding", key.getBytes(StandardCharsets.UTF_8), iv.getBytes(StandardCharsets.UTF_8));
        String s1 = "KIx4D5aFDtQR89fC0nRfc/5AZJi61lYHG/ezMY2Eo79s7Lq/ieIG/T+kmDGWMQqkXQP/n/FsVnbRg42tNJPifa1aTYiJTY0tjjAgn+JCt8T2Ucu4/d/YRtD2IKoMxalqFzvvbyeBYmq2YdWV8I8Wb9as9YvyvDNFR816Vj5af6GOx7cL63oEjxnyG5kc/aTPNOlNwkS/2SqpcAO61A38WQ==";
        String s2 = "qZfKoo5n4UVj979trJVOFHkZRLfgl7fRpNMWB9y9cQO4fGWfJp1z+ahMLsuvpCNtU4JgSwiVmFYSjevBFqE6F+hVBBrp1Cu+K9A2SMQZOr4Yc6FX3k2vGG+aAtVrPkq6PjwpylfRirDcf8OM9fXhRMrMPsVZOPbgP1OanyGmX2G6aWX0t/1FG6gsmDK/V9o/FZ+Egmt4SJFQy2ouWZhm+w==";
        String ds = aes.decryptStr(s2);
        System.out.println(ds);

        byte[] b64 = Base64.decode(s2);
        byte[] de64 = aes.decrypt(b64);
        String b64Str = StrUtil.str(de64, StandardCharsets.UTF_8);
        System.out.println(b64Str);
    }
}
